package com.xie.smfs.screen;

import com.xie.smfs.handler.SecondInventoryScreenHandler;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;

public class ScreenOpener {
    public static void openCustomScreen(PlayerEntity player) {
        if (player.getWorld().isClient) {
            // 客户端直接打开界面
            MinecraftClient client = MinecraftClient.getInstance();
            client.execute(() -> {
                client.setScreen(new SecondInventoryScreen(
                        new SecondInventoryScreenHandler(0, player.getInventory()),
                        player.getInventory(),
                        Text.literal("灵异界面")
                ));
            });
        } else {
            // 服务器端通过NetworkHandler发送打开界面的请求
            // 这里需要实现网络通信
            // YourModNetworkHandler.sendToClient(new OpenCustomScreenPacket(), (ServerPlayerEntity) player);
        }
    }
}